#include "ShaderCompute.h"

using namespace Gut;

#ifdef _WIN32

bool ShaderCompute::CreateFormFile(ShaderFile cFile)
{
	this->ID = glCreateProgram();
	glAttachShader(this->ID, cFile.id);
	glLinkProgram(ID);
	return true;
}

bool ShaderCompute::CreateFormFilePath(std::string cPath)
{
	bool gr;
	ShaderFile cFile;
	ThrowIfFailed(cFile.CreateFromFile(cPath, GL_COMPUTE_SHADER));
	return CreateFormFile(cFile);
}

void TextureCompute::SetReadLayout(int binding, int format)
{
	Bind();
	glBindImageTexture(binding, ID, 0, GL_FALSE, 0, GL_READ_ONLY, format);
}

void TextureCompute::SetWriteLayout(int binding, int format)
{
	Bind();
	glBindImageTexture(binding, ID, 0, GL_FALSE, 0, GL_WRITE_ONLY, format);
}
#else

bool ShaderCompute::CreateFormFile(ShaderFile cFile)
{
	LOGE("Failed Create Compute Shader");
}

bool ShaderCompute::CreateFormFilePath(std::string cPath)
{
	LOGE("Failed Create Compute Shader");
}

void TextureCompute::SetReadLayout(int binding, int format)
{
	LOGE("Failed Create Compute Shader");
}

void TextureCompute::SetWriteLayout(int binding, int format)
{
	LOGE("Failed Create Compute Shader");
}
#endif


